﻿$(document).ready(function () {
    Messages.WriteMessage("Initializing site.");

    var categoriesRoutes = new CategoriesRouter();
    var authorsRoutes = new AuthorsRoutes();
    var booksRoutes = new BooksRoutes();
    var accountRoute = new AccountRoutes();
    var messagesRoute = new MessagesRoutes();
    var friendsRoute = new FriendsRoutes();
    var profileRoute = new ProfileRoutes();
    //This route should be last.
    var contentRoute = new ContentRoutes();
    window.UrlPrefix = Settings.UrlPrefix.Client;
    Backbone.history.start({ pushState: true, root: window.UrlPrefix });
    $(document).on("click", "a:not(.no-link, .ui-dialog-Namebar-close)", function (e) {
        e.preventDefault();
        if ($(this).attr("href")) {
            var url = $(this).attr("href").replace(window.UrlPrefix, '');
            Backbone.history.navigate(url, { trigger: true });
        }
    });
    $.ajaxSetup({
        // Disable caching of AJAX responses
        cache: false
    });
    Messages.WriteMessage("Site initialize successfully.");
});